package com.qfedu.buy.server.controller;

import com.qfedu.buy.common.config.SystemConfig;
import com.qfedu.buy.common.dto.UserLoginDto;
import com.qfedu.buy.common.dto.UserOpDto;
import com.qfedu.buy.common.vo.R;
import com.qfedu.buy.server.service.intf.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: NeighborBuy
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-01-25 15:05
 */
@RestController
@RequestMapping("/server/user/")
public class UserController {
    @Autowired
    private UserService service;

    @GetMapping("/checkphone.do")
    public R checkPhone(@RequestParam String phone){
        return service.checkPhone(phone);
    }
    @GetMapping("/checktoken.do")
    public R checkToken(HttpServletRequest request){
        return service.checkToken(request.getHeader(SystemConfig.TOKEN_HEADER));
    }
    @PostMapping("/register.do")
    public R add(@RequestBody UserOpDto dto){
        return service.register(dto);
    }
    @PostMapping("/login.do")
    public R login(@RequestBody UserLoginDto dto){
        return service.login(dto);
    }



}
